<!DOCTYPE html>
<html>

	<head>

		<meta charset="utf-8">
		<title>用户登录</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
	 
	 

		<style>
			#wx_first input:focus {
				border: none;
				outline: none;
			}
			
			#wx_first label {
				padding-right: 10px;
			}
			
			#wx_first input {
				height: 2.5rem;
				width: 70%;
				font-size: 13px;
				border: none;
				margin: 0;
			}
			
			#wx_first div {
				text-align: center;
				margin: 2rem auto;
			}
			
			.main div {
				border-bottom: 1px #ddd dashed;
			}
			
			#code {
				margin: none;
			}
			
			#wx_first .vicode {
				width: 35%;
				height: 2rem;
				margin: none;
				border: 1px gold solid;
				border-radius: 20px;
				background-color: white;
			}
			
			.main {
				width: 90%;
				text-align: left;
				margin: auto;
			}
			
			#wx_first .vicode:focus {
				border: 1px #EC971F solid;
			}
		</style>

	</head>
<script type="text/javascript">


</script>
	<title></title>

	<body>

		<div id="wx_first" class="">
			<form action="#" method="post" id="loginfrm">

				<p style="color: black;font-family: '微软雅黑'; text-align: center;font-size: 25px;margin: 5rem;">手机号绑定</p>

				<div class=" main">
					<div>
						<label for="phone">手机号</label> <input type="text" name="phone" id="phone" placeholder="请输入手机号" />
					</div>
					<div>
						<label for="referralCode">推荐码</label> <input type="text" name="referralCode" id="referralCode" placeholder="请输入推荐码" />
					</div>
					<div>
						<label for="vcode">验证码</label>
						<input type="text" style="width: 35%;margin: 0;" name="code" id="vcode" placeholder="请输入验证码" /> <input type="button" value="获取验证码" class="vicode" id="submitCode" />

					</div>

					<input type="button" style="background-color:gold;border-radius: 20px;font-size: 20px;color: white;" value="绑定" id="sumbit">

				</div>
			</form>

		</div>
		</div>

	</body>
	<script type="text/javascript">
		$("#sumbit").click(function(){
		  var obj=	$("#loginfrm").serializeObject();
		 console.log(JSON.stringify(obj));
		 if(server.isEmpty(obj.phone) ||obj.phone.length!=11){
			   pop_up("手机号有误！");
			   return ;
		 }
		 if(server.isEmpty(obj.code) ||obj.code.length<4){
			   pop_up(" 验证码有误！");
			   return ;
		 }
		 
		 server.req("wechat/member/build",obj,function(data){
			 pop_up(data.msg);	
			 if(data.code==0){
				// window.location.href=server.url+"index.html#!payorder"
				   server.setCache("token",data.data.openId);
				  server.loadindex("page/home/home")
			 }
		 },null,"POST")
		})
		 var isrun=false;
		
			$("#submitCode").click(function(){
				 var obj=	$("#loginfrm").serializeObject();
				 if(isrun)return;
				 if(server.isEmpty(obj.phone) ||obj.phone.length!=11){
					   pop_up("手机号有误！");
					   return ;
				 }
				server.req("wechat/sms?uuid="+Math.floor(Math.random()*1000000)+"&phone="+obj.phone,null,function(data){
					if(data.code==0){
						//server.formLoad("#loginfrm",{code:data.data})
						isrun=true;
						pop_up("发送成功！");
						$("#submitCode").css("background-color","#AAA");
						window.clearInterval();
						server.autotime(60, ()=>{
						 
							$("#submitCode").css("background-color","white");
							isrun=false;
							},function(t){ 
								if(t==0){
									$("#submitCode").val("获取验证码");  
								}else
								$("#submitCode").val("("+t+")"); });
					}else{
						pop_up(data.msg);
					}
					
				},null,"GET");
			})
			
		
	 
	</script>

</html>